package com.practice.concurrency.signal;


public class Pipeline {

	private final ThreadSignal signal = new ThreadSignal();
	
	public void setupCustomer() {
		for (int i = 0; i < 8; i++) {
			Thread thread = new Thread(new Customer(signal));
			thread.start();
		}
	}
	
	public void setupProducer() {
		for (int i = 0; i < 8; i++) {
			Thread thread = new Thread(new Producer(signal));
			thread.start();
		}
	}
}

class Customer implements Runnable {
	private ThreadSignal signal;
	
	public Customer(ThreadSignal signal) {
		this.signal = signal; 
	}
	
	@Override
	public void run() {
		signal.doWait();
	}
}

class Producer implements Runnable {
	private ThreadSignal signal;
	
	public Producer(ThreadSignal signal) {
		this.signal = signal; 
	}
	
	@Override
	public void run() {
		signal.doNotify();
	}
}
